#include "GameEventManager.h"

GameEventManager g_pEventManager;

char* roundsays[4] = {"say visit www.oldschoolhack.de", "say visit www.thc-crew.net", "say HELL YEAH FUCK YOU!!!", "say SEE THAT? THAT WAS SKILL NIGGA"};

void GameEventManager::Init()
{
	wchar_t szPath[512];
	SD_Tools::GetRealDir(g_pInterfaces.hModuleBase, szPath, 512);
	swprintf(szWav, L"%s\\Hitmarker.wav", szPath); 
	bRoundsay = true;
}

void GameEventManager::FireGameEvent(IGameEvent *event)
{
	const char* szEventName = event->GetName();
	if( !szEventName )
		return;

	if(!lstrcmpA(szEventName, "player_hurt"))
	{
		int me = g_pInterfaces.g_pEngine->GetLocalPlayer();
		int dead = g_pInterfaces.g_pEngine->GetPlayerForUserID(event->GetInt("userid"));
		int killer = g_pInterfaces.g_pEngine->GetPlayerForUserID(event->GetInt("attacker"));
		if(killer == me && dead != me)
		{
			hitplayer = true;
			PlaySound(szWav, NULL, SND_FILENAME|SND_ASYNC|SND_NOSTOP);
		}
	}
}

void GameEventManager::RegisterSelf()
{
	g_pInterfaces.g_pGameEventManager->AddListener( this, "round_start", false );
	g_pInterfaces.g_pGameEventManager->AddListener( this, "player_hurt", false );
}